package com.pospi.pospihold.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pospi.pospihold.R;
import com.pospi.pospihold.dto.TableDto;

import java.util.List;

/**
 * Created by acer on 2018/4/13.
 * 餐桌
 */

public class TableAdapter extends BaseAdapter {
    private Context context;
    private List<TableDto> tablebeens;

    public TableAdapter(Context context, List<TableDto> tablebeens) {
        this.context = context;
        this.tablebeens = tablebeens;
    }

    @Override
    public int getCount() {
        return tablebeens.size();
    }

    @Override
    public Object getItem(int i) {
        return tablebeens.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.item_table, null);
            holder.name = (TextView) view.findViewById(R.id.tv_name);
            holder.tv_area = (TextView) view.findViewById(R.id.tv_area);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.name.setText(tablebeens.get(i).getTablesName());
        holder.tv_area.setText(tablebeens.get(i).gettArea());

        return view;
    }

    class ViewHolder {
        TextView tv_area;
        TextView name;
        RelativeLayout ll;

    }

}
